package com.zyk.leetcode;

/**
 * 字符串轮转。给定两个字符串s1和s2，请编写代码检查s2是否为s1旋转而成（比如，waterbottle是erbottlewat旋转后的字符串）。
 *
 * @author zhangsan
 * @date 2021/4/7 15:59
 */
public class M0109 {

    // https://leetcode-cn.com/problems/string-rotation-lcci/
    // 思路: s2是s1旋转后, s2+s2如果包含s1则是他旋转后的结果
    public static boolean isFlipedString(String s1, String s2) {
        if(s1.length() != s2.length()) {
            return false;
        }
        return (s2+s2).contains(s1);
    }


    // for test
    public static void main(String[] args) {
        String s1 = "aba",
                s2 = "bab";
        System.out.println(isFlipedString(s1, s2));
    }

}
